package org.qy137.controller;

import com.qy137.entity.HeadNav;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.qy137.service.HeadNavService;
import org.qy137.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"headnav"})
@Api
public class HeadNavController {
    @Autowired
    private HeadNavService headNavService;

    public HeadNavController() {
    }

    @ApiOperation("后台分页查询头部导航栏")
    @GetMapping({"getAllHeadNav/{page}/{limit}"})
    public CommonResult getAllHeadNav(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @RequestBody(required = false) HeadNav headNav) {
        return this.headNavService.getAllHeadNav(page, limit, headNav);
    }

    @ApiOperation("删除头部导航栏")
    @DeleteMapping({"deleteHeadNav/{headId}"})
    public CommonResult deleteHeadNav(@PathVariable("headId") Integer headId) {
        return this.headNavService.deleteHeadNav(headId);
    }

    @PutMapping({"changeStatus/{headId}/{isDiable}"})
    @ApiOperation("改变头部导航栏显示状态")
    public CommonResult updateDiable(@PathVariable("headId") Integer headId, @PathVariable("isDiable") String isDiable) {
        return this.headNavService.updateDiable(headId, isDiable);
    }

    @ApiOperation("添加或修改头部导航栏")
    @PostMapping({"addHeadNav"})
    public CommonResult addHeadNav(@RequestBody HeadNav headNav) {
        return this.headNavService.addHeadNav(headNav);
    }
}
